﻿<%@ WebHandler Language="C#" Class="SIPO.Web.AjaxHandler.Loaddata.getDemandForDebtorName" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using SIPO.Library.DataAccess.Transaction;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.Enum;
using System.Text;
using SIPO.Web.Support;
using Newtonsoft.Json.Linq;

namespace SIPO.Web.AjaxHandler.Loaddata
{
    public class getDemandForDebtorName : SIPO.Web.BaseHandler
    {
        recDevolutionRepo devolutionDal = new recDevolutionRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
        
        public override void ProcessRequest(HttpContext context)
        {
            int debtorId = int.Parse(context.Request.Params["DebtorID"].ToString());
            recDemand demand = devolutionDal.GetDemandForDebtorName(debtorId);

            StringBuilder sbProject = new StringBuilder();

            sbProject.Append("{");
            sbProject.AppendFormat("  {0}DemandNo{0}:{0}{1}{0}", "\"", demand.DemandNo);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}DebtorName{0}:{0}{1}{0}", "\"", demand.DebtorName);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}LatterNo{0}:{0}{1}{0}", "\"", demand.recDemandDetail.LatterNo);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}LatterDate{0}:{0}{1}{0}", "\"", demand.recDemandDetail.LatterDate.Value.ToString("dd/MM/yyyy"));
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}TransValue{0}:{0}{1}{0}", "\"", demand.recDemandDetail.TransValue);
            sbProject.Append("}");

            context.Response.Write(sbProject.ToString());
        }

        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}